﻿using Matrix.Common;
using System.ComponentModel;

namespace Matrix.ViewModel
{
   public class MatrixElements : IMatrixElement
   {
      #region IMatrixElement Members
      public MatrixElements(int row, int column)
      {
         this.rowPosition = row;
         this.columnPosition = column;
      }

      double value;
      public double ElementValue
      {
         get
         {
            return value;
         }
         set
         {
            this.value = value;
            OnPropertyChanged("ElementValue");
         }
      }

      private bool isValid = false;
      public bool IsValid
      {
         get
         {
            return isValid;
         }
         set
         {
            isValid = value;
            OnPropertyChanged("IsValid");
         }
      }

      private bool isEditable = true;
      public bool IsEditable
      {
         get
         {
            return isEditable;
         }
         set
         {
            isEditable = value;
            OnPropertyChanged("IsEditable");
         }
      }

      private int columnPosition;
      public int ColumnPosition
      {
         get
         {
            return columnPosition;
         }
         set
         {
            columnPosition = value;
            OnPropertyChanged("ColumnPosition");
         }
      }

      private int rowPosition;
      public int RowPosition
      {
         get
         {
            return rowPosition;
         }
         set
         {
            rowPosition = value;
            OnPropertyChanged("RowPosition");
         }
      }

      #endregion

      #region INotifyPropertyChanged Members

      public event PropertyChangedEventHandler PropertyChanged;

      private void OnPropertyChanged(string propertyName)
      {
         if (PropertyChanged != null)
         {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
         }
      }

      #endregion
   }
}
